<?php
class Adminuser
{
	static function getByUsername($username)
	{
		if(!($username=trim($username)))	return false;
		return Db::get(__CLASS__)->select()->where(array('username'=>$username))->getOne();
	}
	
	static function get($uid)
	{
		return Db::get(__CLASS__)->select()->where(array('id'=>$uid))->getOne();
	}
	
	static function changePasswd($uid, $passwd)
	{
		return Db::get(__CLASS__)->update(array('password'=>$passwd))->where(array('id'=>$uid))->exec();
	}
	
	static function findAll($where=null, $order=null, $s=null, $l=null)
	{
		return Db::get(__CLASS__)->select()->where($where)->order($order)->limit($s,$l)->getAll();
	}
	static function count($where=null)
	{
		return Db::get(__CLASS__)->count()->where($where)->getCol();
	}
	
	static function update($id, $data)
	{
		return Db::get(__CLASS__)->update($data)->where(array('id'=>$id))->exec();
	}
	
	static function add($data)
	{
		return Db::get(__CLASS__)->insert($data)->exec() ? Db::get(__CLASS__)->insertId() : false;
	}
	
	static function delete($id)
	{
		return Db::get(__CLASS__)->delete()->where(array('id'=>$id))->exec();
	}
	
	
}
?>